package com.heima.comment.controller;

import com.heima.comment.dto.CommentDto;
import com.heima.comment.dto.CommentLikeDto;
import com.heima.common.dto.ResponseResult;
import com.heima.comment.dto.CommentSaveDto;
import com.heima.comment.service.ICommentService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api/v1/comment")
public class CommentController {
    @Autowired
    private ICommentService commentService;

    /**
     * 添加评论
     * @param dto
     * @return
     */
    @PostMapping("/save")
    public ResponseResult commentSave(@RequestBody CommentSaveDto dto){
        return commentService.commentSave(dto);
    }

    /**
     * 评论点赞
     * @param dto
     * @return
     */
    @ApiOperation(value = "评论点赞",notes = "author:ztz")
    @PostMapping("like")
    public ResponseResult like(@RequestBody CommentLikeDto dto){
        return commentService.like(dto);
    }

    /**
     * 评论列表分页查询
     * @param dto
     * @return
     */
    @PostMapping("/load")
    public ResponseResult load(@RequestBody CommentDto dto){
        return commentService.load(dto);
    }

}
